package com.tjsiqi.service;

import com.tjsiqi.Vo.WxOrderUnitVo;
import com.tjsiqi.beans.PageQuery;
import com.tjsiqi.beans.PageResult;
import com.tjsiqi.dao.WxOrderUnitMapper;
import com.tjsiqi.model.WxOrderUnit;
import com.tjsiqi.model.WxhntRWD;
import com.tjsiqi.param.SearchwxUnitsParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class WxOrderUnitService {
    @Resource
    private WxOrderUnitMapper wxOrderUnitMapper;
    //获取施工单位列表
    public PageResult<WxOrderUnitVo> getWxOrderUnits(SearchwxUnitsParam param, PageQuery page) {

        if (StringUtils.isNotBlank(param.getStUnit())) {
            param.setStUnit("%" + param.getStUnit() + "%");
        }else{
            param.setStUnit(null);
        }
        int count = wxOrderUnitMapper.countByParam(param);
        if (count > 0){
            List<WxOrderUnitVo> wxOrderUnits = wxOrderUnitMapper.getWxOrderUnitsByParam(param, page);
            return PageResult.<WxOrderUnitVo>builder().total(count).data(wxOrderUnits).build();
        }
        return PageResult.<WxOrderUnitVo>builder().build();
    }
}
